package com.dinner.util;

import com.dinner.model.Consumer;
import com.dinner.model.MenuItem;
import com.dinner.model.MenuType;
import com.dinner.model.Order;
import com.dinner.model.Seller;

public class DinnerFactory {
	
	private DinnerFactory() {
		
	}
	
	public MenuItem newMenuItem() {
		return new MenuItem();
	}
	
	public MenuType newMenuType() {
		return new MenuType();
	}
	
	public Order newOrder() {
		return new Order();
	}
	
	public Seller newSeller() {
		return new Seller();
	}
	
	public Consumer newConsumer() {
		return new Consumer();
	}
	
	@SuppressWarnings("unchecked")
	public IPriceRecounter newPriceRecounter(String recounterName) {
		try{
			Class cl = Class.forName(recounterName);
			return (IPriceRecounter)(cl.newInstance());
		}catch(Exception e){
			e.printStackTrace();
			return null;
		}
	}
		
	
	public static DinnerFactory getFactory() {
		return factory;
	}
	
	private static DinnerFactory factory = new DinnerFactory();
}
